import Page
from Page import Motorcade
from Base.Base import Base
from selenium.webdriver.common.by import By


class MotorcadeSettingPage(Base):
    """
    车队信息设置界面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.setting_home_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.setting_back_btn = (By.XPATH, Motorcade.RESOURCE_ID.format('ivBack'))

        # 信息设置标题
        self.setting_information_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("setting_title_tv"))

        # 退出车队按钮
        self.setting_quit_car_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("exit_motorcade"))

        # 我的口令标题
        self.setting_my_password_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title_command_tv"))

        # 我的口令数字
        self.setting_my_password_number_text = (By.XPATH, Motorcade.RESOURCE_ID.format("command_tv"))

        # 我的口令选中框
        self.setting_my_password_select_icon = (By.XPATH, Motorcade.RESOURCE_ID.format("motorcade_command_cl"))

        # 车队名称标题
        self.setting_car_name_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title_name_tv"))

        # 车队名称
        self.setting_car_name_text = (By.XPATH, Motorcade.RESOURCE_ID.format("name_tv"))

        # 车队名称选中框
        self.setting_car_name_select_icon = (By.XPATH, Motorcade.RESOURCE_ID.format("motorcade_name_cl"))

        # 个人名称标题
        self.setting_personal_name_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title_nickname_tv"))

        # 个人名称
        self.setting_personal_name_text = (By.XPATH, Motorcade.RESOURCE_ID.format("nickname_tv"))

        # 个人名称选中框
        self.setting_personal_name_select_icon = (By.XPATH, Motorcade.RESOURCE_ID.format("motorcade_nickname_cl"))

        # 是否收听其他车主标题
        self.setting_listen_car_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title_listen_voice_tv"))

        # 收听开关
        self.setting_listen_car_ok_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("listen_voice_switch"))

        # 当前在线人数标题
        self.setting_online_users_text = (By.XPATH, Motorcade.RESOURCE_ID.format("online_count_tv"))

        # 车主头像
        self.setting_list_car_avatar_icon = (By.XPATH, Motorcade.car_users_list_avatar_icon.format(""))

        # 群主图标
        self.setting_list_lord_icon = (By.XPATH, Motorcade.car_user_lord_icon.format(""))

        # 车主名称
        self.setting_user_name_text = (By.XPATH, Motorcade.car_user_name_text.format(""))

        # 离线在线状态
        self.setting_offline_text = (By.XPATH, Motorcade.car_user_on_offline_text.format(""))

        # 车队名称标题
        self.setting_car_one_name_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title"))

        # 车队名称输入框
        self.setting_car_user_name_input = (By.XPATH, Motorcade.RESOURCE_ID.format("blt_name_et"))

        # 确认按钮
        self.setting_ok_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("confirm"))

        # 取消按钮
        self.setting_no_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("cancel"))

        # 个人名称标题
        self.setting_car_two_name_title_text = (By.XPATH, Motorcade.RESOURCE_ID.format("title"))

        # 个人名称输入框
        self.setting_car_two_user_name_input = (By.XPATH, Motorcade.RESOURCE_ID.format("blt_name_et"))

        # 个人确认按钮
        self.setting_two_ok_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("confirm"))

        # 个人取消按钮
        self.setting_two_no_btn = (By.XPATH, Motorcade.RESOURCE_ID.format("cancel"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.setting_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.setting_back_btn)

    def get_information_title(self):
        """
        获取信息设置标题

        :return:获取元素
        """
        return self.find_element_o(self.setting_information_title_text)

    def click_quit_car(self):
        """
        点击退出车队按钮

        :return:None
        """
        self.click_element(self.setting_quit_car_btn)

    def get_my_password_title(self):
        """
        获取我的口令标题

        :return:获取元素
        """
        return self.find_element_o(self.setting_my_password_title_text)

    def get_my_password_number(self):
        """
        获取我的口令数字

        :return:获取元素
        """
        return self.find_element_o(self.setting_my_password_number_text)

    def click_my_password_select(self):
        """
        点击我的口令选中框

        :return:None
        """
        self.click_element(self.setting_my_password_select_icon)

    def get_car_name_title(self):
        """
        获取车队名称标题

        :return:获取元素
        """
        return self.find_element_o(self.setting_car_name_title_text)

    def get_car_name(self):
        """
        获取车队名称

        :return:获取元素
        """
        return self.find_element_o(self.setting_car_name_text)

    def click_car_name_select(self):
        """
        点击车队名称选中框

        :return:None
        """
        self.click_element(self.setting_car_name_select_icon)

    def get_personal_name_title(self):
        """
        获取个人名称标题

        :return:获取元素
        """
        return self.find_element_o(self.setting_personal_name_title_text)

    def get_personal_name(self):
        """
        获取个人名称

        :return:获取元素
        """
        return self.find_element_o(self.setting_personal_name_text)

    def click_personal_name_select(self):
        """
        点击个人名称选中框

        :return:None
        """
        self.click_element(self.setting_personal_name_select_icon)

    def get_listen_car_title(self):
        """
        获取其他车主收听标题

        :return:获取元素
        """
        return self.find_element_o(self.setting_listen_car_title_text)

    def click_listen_car_ok(self):
        """
        点击收听开关

        :return:None
        """
        self.click_element(self.setting_listen_car_ok_btn)

    def get_listen_car_ok_select(self):
        """
        获取收听开关状态

        :return:获取元素
        """
        return self.find_element_o(self.setting_listen_car_ok_btn)

    def get_online_users(self):
        """
        获取当前在线人数标题

        :return:获取元素
        """
        return self.find_element_o(self.setting_online_users_text)

    def get_list_car_avatar(self, index=1):
        """
        获取车主头像

        index默认是1
        :return:获取元素
        """
        self.setting_list_car_avatar_icon = (By.XPATH, Motorcade.car_users_list_avatar_icon.format(index))
        return self.find_element_o(self.setting_list_car_avatar_icon)

    def get_list_lord(self, index=1):
        """
        获取群主图标

        index默认是1
        :return:获取元素
        """
        self.setting_list_lord_icon = (By.XPATH, Motorcade.car_user_lord_icon.format(index))
        return self.find_element_o(self.setting_list_lord_icon)

    def get_user_name(self, index=1):
        """
        获取车主名称

        index默认是1
        :return:获取元素
        """
        self.setting_user_name_text = (By.XPATH, Motorcade.car_user_name_text.format(index))
        return self.find_element_o(self.setting_user_name_text)

    def get_offline(self, index=1):
        """
        获取是否在线

        index默认是1
        :return:获取元素
        """
        self.setting_offline_text = (By.XPATH, Motorcade.car_user_on_offline_text.format(index))
        return self.find_element_o(self.setting_offline_text)

    def is_display_motorcade_setting(self):
        """
        是否进入车队详情页

        :return: bool
        """
        return self.is_display(self.setting_information_title_text)

    def get_car_one_name_title(self):
        """
        获取车队名称标题

        :return: 获取元素
        """
        return self.find_element_o(self.setting_car_one_name_title_text)

    def input_car_user_name(self, index):
        """
        输入车队名称

        index为输入的车队名称
        :return: 获取元素
        """
        return self.input_text(self.setting_car_user_name_input, index)

    def click_ok(self):
        """
        点击确认键

        :return: None
        """
        self.click_element(self.setting_ok_btn)

    def click_no(self):
        """
        点击取消键

        :return: None
        """
        self.click_element(self.setting_no_btn)

    def is_display_motorcade_car_name(self):
        """
        是否进入车队名称弹窗

        :return: bool
        """
        return self.is_display(self.setting_car_one_name_title_text)

    def get_car_two_name_title(self):
        """
        获取车队名称标题

        :return: 获取元素
        """
        return self.find_element_o(self.setting_car_two_name_title_text)

    def input_car_two_user_name(self, index):
        """
        输入车队名称

        index为输入的车队名称
        :return: 获取元素
        """
        return self.input_text(self.setting_car_two_user_name_input, index)

    def click_two_ok(self):
        """
        点击确认键

        :return: None
        """
        self.click_element(self.setting_two_ok_btn)

    def click_two_no(self):
        """
        点击取消键

        :return: None
        """
        self.click_element(self.setting_two_no_btn)

    def is_display_motorcade_car_user(self):
        """
        是否进入个人名称弹窗

        :return: bool
        """
        return self.is_display(self.setting_car_two_name_title_text)

    def is_toast_setting(self, index):
        """
        判断弹窗是否出现

        :return: bool
        """
        return self.is_toast_exist(text=index)


if __name__ == '__main__':
    pass
